extends "../cTDW_4/cTDW_4.gd"
func _info():
	pass

func _connect():
	._connect()

func _extInit():
	._extInit()
	chaName = "蛮锤战士"
	lv = 3
	attCoe.atk = 33 / 8.5 * 2 / 3
	attCoe.maxHp = 1100 / 112.5 / 3
	attCoe.def = 25 / 15.0 / 3.0
	attCoe.mgiDef = 25 / 16.6 / 3.0
	addSkillTxt("加重锤：普攻15%概率扔出一把加重锤，击退敌人1格并额外造成（30+50%物攻）真伤")
	addCdSkill("mcqs",5)
	addSkillTxt("兴奋：物攻+17点，攻速+15%[cd：5秒；持续至战斗结束,可叠加效果]")

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "mcqs":
		cst("兴奋","000000",position)
		self.addBuff(xf.new(1))

class xf:
	extends Buff
	func _init(lv):
		attInit()
		id = "buff_xf"
		att.atk = 17
		att.spd = 0.15

var pw1:int = 15
var pw2:int = 10

func _onNormalAtk(cha):
	#print(att.atk)
	if sys.rndPer(pw1):
		cst("加重锤","000000",position)
		hurtChara(cha,30 + att.atk*0.5,Chara.HurtType.REAL,Chara.AtkType.SKILL)
		var ccell = cha.cell
		var ncell = cha.cell
		if ccell.x != cell.x:
			if ccell.x > cell.x:
				ncell.x = min(9,ccell.x + 1)
			else:
				ncell.x = max(0,ccell.x - 1)
		else:
			if ccell.y > cell.y:
				ncell.y = min(5,ccell.y + 1)
			else:
				ncell.y = max(0,ccell.y - 1)
		if cha.setCell(ncell):
			var pos = sys.main.map.map_to_world(cha.cell)
			ying(pos, cha.position)
			cha.position = pos
			cha.aiCha = null
			aiCha = null
			cst("被击退","FFFFFF",cha.position + Vector2(0,-50))
			
	elif sys.rndPer(pw2) && self.id != "cTDW_4_1":
		cst("爆炸锤","000000",position)
		var chas = getAllChas(1)
		for i in chas:
			if abs(i.cell.x - cha.cell.x) <= 2 && abs(i.cell.y - cha.cell.y) <=2:
				hurtChara(i,att.atk*0.8,Chara.HurtType.PHY,Chara.AtkType.SKILL)